

/*========== CREATE TABLES ============*/
local j = 1
local q = `j'*100
local d = 1
local spec = 3

use "${data1}regready_cps_ipums_84.dta" , clear
if `spec'<3 replace contpov = contpov_dube
gen under = contpov < `j'

cap program drop mydisp
program mydisp, eclass
         matrix betass=e(b)
         matrix colnames betass = "E"
         mat list betass
         ereturn repost b = betass, rename
 end


local append outreg, merge(r) starloc(1) var stats(b se) blankrow  merge starlevels(10 5 1) bdec(4) noau  keep(lnMW ) nolegend
local append1 outreg, merge(r) starloc(1) var stats(b se) blankrow  merge starlevels(10 5 1) bdec(4) noau   nolegend



outreg, clear
/*Short Run*/
estimates use "${est}ster/other/MW1_Yearly_2014_`spec'"
sum under [aw=asecwt] if dem1==1 & year<=2014
local DVmean=   `r(mean)'
di `DVmean'
lincom lnMW 
local beta = `r(estimate)'
di `beta'
local elas:  di %5.3f `beta'/`DVmean'
di `elas'
lincomest lnMW 
mydisp
outreg, store(r)  starloc(1) replace var stats(b se )  blankrow starlevels(10 5 1) bdec(4) noau nolegend ///
addrow("Elast", "[`elas']"\"","`obs'") ct("","(1)"   )


forvalues year = 2015/2020 {
	sum under [aw=asecwt] if dem1==1 & year<=`year'
	local DVmean=   `r(mean)'
	di `DVmean'
  estimates use "${est}ster/other/MW1_Yearly_`year'_`spec'"
  lincom lnMW
  local beta = `r(estimate)'
  di `beta'
  local elas:  di %5.3f `beta'/`DVmean'
  di `elas'
  lincomest lnMW
  mydisp
  `append1' addrow("Elast", "[`elas']"\"","`obs'") ct("","(`spec')"   )
}
outreg, replay append(r)

/*Long Run*/
estimates use "${est}ster/other/MW2_Yearly_2014_`spec'"
sum under [aw=asecwt] if dem1==1 & year<=2014
local DVmean=   `r(mean)'
di `DVmean'
local obs : display %11.0gc `e(N)'
lincom lnMW +lnMWL1 +lnMWL2 +lnMWL3
local beta = `r(estimate)'
di `beta'
local elas:  di %5.3f `beta'/`DVmean'
di `elas'
lincomest lnMW +lnMWL1 +lnMWL2 +lnMWL3 
mydisp
outreg, store(r)  starloc(1) replace var stats(b se )  blankrow starlevels(10 5 1) bdec(4) noau nolegend ///
addrow("Elast", "[`elas']"\"","`obs'") ct("","(1)"   )



forvalues year = 2015/2020 {
	sum under [aw=asecwt] if dem1==1 & year<=`year'
	local DVmean=   `r(mean)'
	di `DVmean'
  estimates use "${est}ster/other/MW2_Yearly_`year'_`spec'"
  local obs : display %11.0gc `e(N)'
  lincom lnMW +lnMWL1 +lnMWL2 +lnMWL3
  local beta = `r(estimate)'
  di `beta'
  local elas:  di %5.3f `beta'/`DVmean'
  di `elas'
  lincomest lnMW +lnMWL1 +lnMWL2 +lnMWL3
  mydisp
  `append1' addrow("Elast", "[`elas']"\"","`obs'") ct("","(`d')"   )

}


outreg, replay append(r)
outreg using "${est}other_reg/dube_yearly_robust_`spec'", statfont( fs12 ) basefont(fs12) replay replace landscape


